package com.JingYan.service.impl;

import com.JingYan.service.TianLianVerificationService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.DefaultTransactionDefinition;

/**
 * @program: JingYan
 * @ClassName: TianLianVerificationServiceImpl.java
 * @author: DongJiaQi
 * @version: 1.0.0
 * @Description:
 * @createTime 2023年09月23日 16:51:00
 */
@Slf4j
@Service
public class TianLianVerificationServiceImpl implements TianLianVerificationService {
    @Autowired
    private PlatformTransactionManager txManager;
    @Override
    public void presZcflCheck(String checkMon) {
        log.info("枚举类实现方法");

        // 手动开启事务  start
        DefaultTransactionDefinition def = new DefaultTransactionDefinition();
        def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
        TransactionStatus status = txManager.getTransaction(def);

        try {
            log.info("执行sql操作");
            txManager.commit(status);
        } catch (Exception e) {
            txManager.rollback(status);
            throw new RuntimeException(e);
        }
    }
}
